import React, {useEffect} from 'react';
import {connect} from 'react-redux';
import {getlist} from './redux/actionCreator/ListActions'


const List = (props) => {
    useEffect(()=>{
        if(props.list.length===0){
            props.getlist()
            console.log('重新获取')
        }else{
            console.log('缓存')
        }
    },[])
    return (
        <div>
            {props.list.map(item=>{
                return <li key={item.cinemaId}>{item.name}</li>
            })}
        </div>
    );
}

export default connect((state)=>{
    return {
        list:state.ListReducer.list
    }
},{
    getlist
})(List);
